"use strict";
var util = {
    isFunction: function(obj) {
        return typeof(obj) === "function";
    },

    validateName: function(name) {
        if (/[^0-9a-zA-Z_\.]+/.test(name)) {
            throw new Error("[jNs] unexpect character in name: " + RegExp.lastMatch.replace(/\s/g, "_"));
        }
    },

    mergeNs: function() {
        return [].slice.call(arguments).map(function(t) {
            if (typeof t !== "string") {
                return "";
            }
            return t.replace(/^[\s\.]*|[\s\.]*$/g, "");
        }).filter(function(t) {
            return t;
        }).join(".").replace(/\.{2,}/g, ".");
    },

    splitFullName: function(fullName) {
        var parts = fullName.split(/\./);
        return {
            name: parts.splice(parts.length - 1)[0],
            ns: parts.join(".")
        };
    }
};
